package com.guapi.event;

import cn.hutool.json.JSONUtil;
import com.guapi.dao.Event;
import com.guapi.util.KafkaConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

@Component
public class EventProducer implements KafkaConstant {
    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void sendEvent(Event event){
        kafkaTemplate.send(event.getTopic(), JSONUtil.toJsonStr(event));
    }
}
